package com.learn.hibernatevalidator.chapter05.groupsequenceprovider;

import org.hibernate.validator.spi.group.DefaultGroupSequenceProvider;

import java.util.ArrayList;
import java.util.List;

/**
 * @author: liyf
 * @create: 2025-01-05 22:52
 **/
public class RentalCarGroupSequenceProvider implements DefaultGroupSequenceProvider<RentalCar> {

    @Override
    public List<Class<?>> getValidationGroups(RentalCar rentalCar) {
        List<Class<?>> defaultGroupSequence = new ArrayList<Class<?>>();

        defaultGroupSequence.add(RentalCar.class);

        if (rentalCar != null && !rentalCar.isRented()) {
            defaultGroupSequence.add(CarChecks.class);
        }

        return defaultGroupSequence;
    }
}
